package cn.group.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import utils.BaseController;
import utils.BrowserUtils;
import utils.IPHelper;

import javax.servlet.http.HttpServletRequest;

@Api(tags = "IP获取")
@Controller
@RequestMapping(value = "/port" , produces = "text/html;charset=UTF-8")
public class PortController extends BaseController {

    IPHelper ipHelper=new IPHelper();
    BrowserUtils browserUtils=new BrowserUtils();

    @ApiOperation("获取用户IP信息")
    @RequestMapping(value = "/ipPort.do")
    @ResponseBody
    public String IPMassage(HttpServletRequest request){
        String ipAddress = ipHelper.getIpAddress(request);
        String ip = writerSuccessResult(ipAddress);
        return ip;
    }
    @ApiOperation("获取用户浏览器信息")
    @RequestMapping(value = "/browser.do")
    @ResponseBody
    public String browserMassage(HttpServletRequest request){
        String url = request.getHeader("USER-AGENT");
        String  browser = browserUtils.getBrowser(url);
        String ip = writerSuccessResult(browser);
        return ip;
    }
}
